//
//  AccountDetailViewController.m
//  sys_eric
//
//  Created by mac on 11-11-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "AccountDetailViewController.h"


@implementation AccountDetailViewController
@synthesize enterpriseName;
@synthesize loginName;
@synthesize settelmentWay;
@synthesize messageValue;
@synthesize numberOfSendableMessage;
@synthesize startPermissionSndTime;
@synthesize endPermissionSndTime;

//使用前需要在.h文件中声明uitextfield实例变量
-(void)backgroundTap
{
    [enterpriseName resignFirstResponder];
    [loginName resignFirstResponder];
    [settelmentWay resignFirstResponder];
    [messageValue resignFirstResponder];
    [numberOfSendableMessage resignFirstResponder];
    [startPermissionSndTime resignFirstResponder];
    [endPermissionSndTime resignFirstResponder];
}

- (void)viewDidLoad
{
    self.title=@"企业账户信息";
    UITableView *tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 480) style:UITableViewStyleGrouped];
    self.tableView=tab;
    UIControl *background=[[UIControl alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    [background addTarget:self action:@selector(backgroundTap) forControlEvents:UIControlEventTouchUpInside];
    self.tableView.backgroundView=background; 
    UIEdgeInsets edgeinsets=UIEdgeInsetsMake(40, 0, 0, 0);//为什么只有前两个参数起作用？？？
    self.tableView.contentInset=edgeinsets;
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.scrollEnabled=NO;
    [tab release];
    [super viewDidLoad];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Configure the cell...
	switch (indexPath.row) {
		case 0:
        {cell.textLabel.text = @"企业名称:";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(100,4,150, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
		case 1:
        {cell.textLabel.text = @"登陆名称:";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(100,4,150, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
		case 2:
        {cell.textLabel.text = @"结算方式:";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(100,4,150, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
		case 3:
        {cell.textLabel.text = @"短信单价:";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(100,4,150, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
        case 4:
        {cell.textLabel.text = @"短信帐号可发数量:";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(170,4,100, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
		case 5:
        {cell.textLabel.text = @"允许发送时间（起始):";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(200,4,90, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
		case 6:
        {cell.textLabel.text = @"允许发送时间（终止):";
            UITextField *enterprise=[[UITextField alloc] initWithFrame:CGRectMake(200,4,90, 35)];
		    self.enterpriseName=enterprise;
			enterprise.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
			enterprise.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
			[cell.contentView addSubview:enterprise];
			enterprise.delegate = self;
            enterprise.secureTextEntry=YES;
            enterprise.keyboardType=UIKeyboardTypeDefault;
            [enterprise release];
			break;}
        default:
			break;
	}
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}
-(void)commitChangePswd
{
    NSLog(@"commitChangePswd");
}

-(void)cancelChangePswd
{
    NSLog(@"cancelChangePswd");
}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [enterpriseName release];
    [loginName release];
    [settelmentWay release];
    [messageValue release];
    [numberOfSendableMessage release];
    [startPermissionSndTime release];
    [endPermissionSndTime release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


- (void)viewDidUnload
{
    self.enterpriseName=nil;
    self.loginName=nil;
    self.settelmentWay=nil;
    self.messageValue=nil;
    self.numberOfSendableMessage=nil;
    self.startPermissionSndTime=nil;
    self.endPermissionSndTime=nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}



/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
}

@end
